<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<%@include file="/jsp/common/head.jsp"%>
<div class="right">
	<div class="location">
		<strong>你现在所在的位置是:</strong>
		<span>用户管理页面</span>
	</div>
	<div class="search">
<%--		不带分页--%>
<%--	<form method="post" action="${pageContext.request.contextPath }/users?method=userList">--%>
<%--	    带分页--%>
		<form method="post" action="/userListPage">
			<input name="method" value="query" class="input-text" type="hidden">
			<span>用户名：</span>
			<input name="queryName" class="input-text"	type="text" value="${queryUserName }">

			<span>用户角色：</span>
			<select name="queryUserRole">
				<option value="0">--请选择--</option>
				<c:forEach items="${roleList}" var="role">
					<option value="${role.id}">${role.roleName}</option>
				</c:forEach>
			</select>

			<input type="hidden" name="pageNo" value="1"/>
			<input	value="查 询" type="submit" id="searchbutton">
			<a href="/toUserAdd" >添加用户</a>
		</form>
	</div>
	<!--用户-->
	<table class="providerTable" cellpadding="0" cellspacing="0">
		<tr class="firstTr">
			<th width="10%">用户编码</th>
			<th width="20%">用户名称</th>
			<th width="10%">性别</th>
			<th width="10%">年龄</th>
			<th width="10%">电话</th>
			<th width="10%">用户角色</th>
			<th width="30%">操作</th>
		</tr>
		<!-- 不带分页 -->
		<%-- <c:forEach items="${userList}" var="user"> --%>
		<!-- 带分页 -->
		<c:forEach items="${pageSupport.data}" var="user">
			<tr>
				<td>
					<span>${user.userCode}</span>
				</td>
				<td>
					<span>${user.userName}</span>
				</td>
				<td>
					<span>${user.gender == 1 ? "女" : "男"}</span>
				</td>
				<td>
					<span>${user.userAge}</span>
				</td>
				<td>
					<span>${user.phone}</span>
				</td>
				<td>
					<span>${user.roleName}</span>
				</td>
				<td>
					<span><a class="viewUser" href="/userInfo/${user.id}"><img src="${pageContext.request.contextPath }/images/read.png" alt="查看" title="查看"/></a></span>
					<span><a class="modifyUser" href="/toUserMod/${user.id}"><img src="${pageContext.request.contextPath }/images/xiugai.png" alt="修改" title="修改"/></a></span>
					<span><a class="deleteUser" href="/userDel/${user.id}" ><img src="${pageContext.request.contextPath }/images/schu.png" alt="删除" title="删除"/></a></span>
				</td>
			</tr>
		</c:forEach>

	</table>
	<!-- rest风格删除新闻的form表单 -->
	<form action="#" method="post" id="deleteForm">
		<input type="hidden" name="_method" value="delete" />
	</form>
	<c:import url="rollpage.jsp"></c:import>
</div>
</section>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeUse">
	<div class="removerChid">
		<h2>提示</h2>
		<div class="removeMain">
			<p>你确定要删除该用户吗？</p>
			<a href="#" id="yes">确定</a>
			<a href="#" id="no">取消</a>
		</div>
	</div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.3.min.js" ></script>
<script type="text/javascript">
	$(function (){
		// 点击删除，使用rest风格，实现删除操作
		$(".deleteUser").click(function (){
			// 删除提示
			if(!confirm("确定要删除吗？")){
				// 取消超链接跳转事件
				return false;
			}

			// 确定删除，rest风格必须使用post改为delete，不能直接超链接发送请求，必须使用表单
			// 将删除超链接的url交给表单提交就可以了
			$("#deleteForm").attr("action", $(this).attr("href")).submit();

			// 去除超链接的跳转事件
			return false;
		})
	})
</script>

<%@include file="/jsp/common/foot.jsp" %>
